#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<cstring>
#include<queue>
#define x first
#define y second
using namespace std;
using pii = pair<int, int>;
const int N = 1010;
int n, ans;
pii q[N * N * 3];
char g[N][N], cg[N][N];
bool st[N][N];
int dx[] = { 1,0,-1,0 }, dy[] = { 0,-1,0,1 };
bool judge(int x, int y)
{
    for (int i = 0; i < 4; i++)
    {
        int a = x + dx[i], b = y + dy[i];
        if (a < 0 || b < 0 || a >= n || b >= n) continue;
        if (g[a][b] == '.') return true;
    }
    return false;
}
void bfs(int x, int y)
{
    int hh = 0, tt = 0;
    q[0] = { x,y };
    st[x][y] = true;
    while (hh <= tt)
    {
        auto t = q[hh++];
        if (judge(t.x, t.y)) cg[t.x][t.y] = '.';

        for (int i = 0; i < 4; i++)
        {
            int a = t.x + dx[i], b = t.y + dy[i];
            if (a < 0 || b < 0 || a >= n || b >= n || g[a][b] == '.' || st[a][b]) continue;
            st[a][b] = true;
            q[++tt] = { a,b };
        }
    }
    int i = 0;
    for (; i <= tt; i++)
    {
        int a = q[i].x, b = q[i].y;
        if (cg[a][b] == '#') break;
    }
    if (i > tt) ans++;
    //cout<<tt<<endl;
}
int main()
{
    cin >> n;
    for (int i = 0; i < n; i++) cin >> g[i];
    memcpy(cg, g, sizeof g);
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (cg[i][j] == '#' && !st[i][j]) bfs(i, j);
        }
    }
    //for(int i=0;i<n;i++) cout<<cg[i]<<endl;
    cout << ans << endl;
    return 0;
}